package cn.wolfcode.query;


import java.util.Collections;
import java.util.List;

import lombok.Getter;
@Getter
public class PageResult<T> {
	private int currentPage;
	private int pageSize;
	private List<T> result;
	private int rows;
	private int prevPage;
	private int nextPage;
	private int totalPage;
	public PageResult(int currentPage, int pageSize, List<T> result, int rows) {
		super();
		this.currentPage = currentPage;
		this.pageSize = pageSize;
		this.result = result;
		this.rows = rows;
		totalPage= rows%pageSize==0?rows/pageSize:rows/pageSize+1;
		prevPage=currentPage-1>1?currentPage-1:1;
		nextPage=currentPage+1<totalPage?currentPage+1:totalPage;
	}
	public static PageResult empty(int pageSize) {
		return new PageResult(1,pageSize,Collections.EMPTY_LIST,0);
	}
}
